# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.action_chains import ActionChains
import unittest
import random
import time
from cookies import lasthopes, randomword
import re
import string
import sys
from selenium.webdriver.common.keys import Keys
from PIL import Image
from os import remove, listdir, sep
from os.path import basename, isfile
import tempfile
from warnings import warn
from basecart import BaseCart

class order_good_credentials(BaseCart):
    def test_order_good_credentials(self):
        driver = self.driver
        self.get_cat()
        self.get_item()
        self.buy_item()
        self.go_cart()
        cred_block = self.perform_order()
        cred_block = WebDriverWait(self.driver, timeout=10)\
                            .until(lambda dr: dr.find_element_by_css_selector("div.b-order-block"))
        self.fill_basecreds(cred_block)
        spb = WebDriverWait(driver, timeout=10)\
                .until(lambda dr: dr.find_element_by_css_selector("div.b-order-foot-container"))\
                                    .find_element_by_css_selector("input.b-sbutton-input")
        spb.click()
        try:
            self.find_error_tooltip(driver, '')
            raise Exception('Must not have any error tooltips inside credentials block')
        except: 
            print 'No tooltips, ok.'
